// 仓库管理
/* 仓库管理模块接口 */
import request from '@/utils/request';
import { rsaEncrypt } from '@/utils/commonUtil3';
// 获取左侧树形结构列表
export const reqWarehouseTreeList = () => request({ url: '/warehouse/selectAll', method: 'GET' });
// 获取仓库详情
export const reqWarehouseDetail = data => request({ url: '/warehouse/selectDetails', method: 'GET', params: { ...data } });
// 添加仓库
export const reqAddWarehouse = data => request({ url: '/warehouse/insert', method: 'POST', data: { data: rsaEncrypt(data) } });
// 删除仓库
export const reqDelWarehouseById = data => request({ url: '/warehouse/delete', method: 'DELETE', data: { data: rsaEncrypt(data) } });
// 回显仓库信息
export const reqWarehouseDetailById = data => request({ url: '/warehouse/getById', method: 'GET', params: { ...data } });
// 修改仓库信息
export const reqEditWarehouse = data => request({ url: '/warehouse/update', method: 'PUT', data: { data: rsaEncrypt(data) } });
// 新增区域
export const reqAddRegion = data => request({ url: '/warehouse/region/insert', method: 'POST', data: { data: rsaEncrypt(data) } });
// 修改区域信息
export const reqEditRegion = data => request({ url: '/warehouse/region/update', method: 'PUT', data: { data: rsaEncrypt(data) } });
// 删除区域
export const reqDelRegionById = data => request({ url: '/warehouse/region/delete', method: 'DELETE', data: { data: rsaEncrypt(data) } });
// 查询区域仓位信息
export const reqRegionPositionDetail = data => request({ url: '/warehouse/region/selectPosition', method: 'GET', params: { ...data } });
// 查询区域商品信息
export const reqRegionCommodityDetail = data => request({ url: '/warehouse/region/selectCommodity', method: 'GET', params: { ...data } });
// 新增仓位
export const reqAddRegionPosition = data => request({ url: '/warehouse/position/insert', method: 'POST', data: { data: rsaEncrypt(data) } });
// 修改仓位信息
export const reqEditRegionPosition = data => request({ url: '/warehouse/position/update', method: 'PUT', data: { data: rsaEncrypt(data) } });
// 删除仓位
export const reqDelPositionById = data => request({ url: '/warehouse/position/delete', method: 'DELETE', data: { data: rsaEncrypt(data) } });
// 商品分类的树形结构
export const reqGoodsCategory = () => request({ url: '/category/simple/select', method: 'GET' });
// 查询添加商品的表格数据
export const reqAddGoodsTableList = data => request({ url: '/commodityRegion/select', method: 'GET', params: { ...data } });
// 给区域添加商品
export const reqAddGoodsForRegion = data => request({ url: '/commodityRegion/insert', method: 'POST', data: { data: rsaEncrypt(data) } });
// 删除区域商品
export const reqDelGoodsById = data => request({ url: '/commodityRegion/delete', method: 'DELETE', data: { data: rsaEncrypt(data) } });
// 修改区域商品
export const reqEditRegionGoods = data => request({ url: '/commodityRegion/update', method: 'PUT', data: { data: rsaEncrypt(data) } });
// 查询仓库下区域列表
export const reqRegionList = data => request({ url: '/warehouse/region/selectByWarehouse', method: 'GET', params: { ...data } });
// 查询区域下的通道
export const reqAisleListById = data => request({ url: '/warehouseAisle/selectByRegion', method: 'GET', params: { ...data } });

/* 商品库存接口 */
// 获取商品列表
export const reqGoodsInvList = data => request({ url: '/commodityInventory/select', method: 'GET', params: { ...data } });
// 获取仓库列表
export const reqWarehouseList = () => request({ url: '/warehouse/selectInfo', method: 'GET' });

// 根据供应商查询进行中的订单
export const getOrderListBySupplier = data => request({ url: '/buyOrder/selectBySupplier', method: 'GET', params: { ...data } });
// 查询采购订单详情
export const getOrderDetailById = data => request({ url: '/buyOrder/selectDetails', method: 'GET', params: { ...data } });

// 添加收货单
export function addReceivingOrderList(data) {
	const data1 = rsaEncrypt(data);
	return request({
		url: '/takeDelivery/insert',
		method: 'post',
		data: {
			data: data1
		}
	});
}

// 分页条件查询收货列表
export function getReceivingOrderList(data) {
	return request({
		url: '/takeDelivery/select',
		method: 'get',
		params: data
	});
}

// 获取收货单详情
export function getReceivingOrderDetail(data) {
	return request({
		url: '/takeDelivery/selectDetails',
		method: 'get',
		params: data
	});
}

// 根据供应商获取待入库收货订单
export function getReceivingOrderListBySupplier(data) {
	return request({
		url: '/takeDelivery/selectBySupplier',
		method: 'get',
		params: data
	});
}

// 查询收货详情入库使用
export function selectDeliveryDetails(data) {
	return request({
		url: '/takeDelivery/selectDeliveryDetails',
		method: 'get',
		params: data
	});
}

// 获取商品对应的仓位
export function selectForInbound(data) {
	return request({
		url: '/warehouse/position/selectForInbound',
		method: 'get',
		params: data
	});
}

// 添加入库记录
export function addInboundRecord(data) {
	const data1 = rsaEncrypt(data);
	return request({
		url: '/inbound/insert',
		method: 'post',
		data: {
			data: data1
		}
	});
}

// 分页条件查询入库记录
export function getInboundSelectist(data) {
	return request({
		url: '/inbound/select',
		method: 'get',
		params: data
	});
}

// 查询入库记录详情
export function getInboundRecordDetail(data) {
	return request({
		url: '/inbound/selectDetails',
		method: 'get',
		params: data
	});
}

// 模糊搜索商品
export function fuzzySearchGoods(data) {
	return request({
		url: '/commodity/findLike',
		method: 'get',
		params: data
	});
}

// 根据商品、仓库查询信息
export function getOrderByGoodsSupplier(data) {
	return request({
		url: '/commodityPosition/selectByCommodity',
		method: 'get',
		params: data
	});
}

// 添加采购退货
export function addBuyReturns(data) {
	const data1 = rsaEncrypt(data);
	return request({
		url: '/buyReturns/insert',
		method: 'post',
		data: {
			data: data1
		}
	});
}

// 分页条件查询退货记录
export function getBuyReturnsSelectist(data) {
	return request({
		url: '/buyReturns/select',
		method: 'get',
		params: data
	});
}

// 查询退货详情
export function getBuyReturnsRecordDetail(data) {
	return request({
		url: '/buyReturns/selectDetails',
		method: 'get',
		params: data
	});
}

// 获取可返仓的记录
export function getBuyReturnsRecord(data) {
	return request({ url: '/returnWare/getForIn', method: 'get', params: data });
}

// 合并选择可返仓的记录
export function mergeBuyReturnsRecord(data) {
	// const data1 = rsaEncrypt(data);
	return request({
		url: '/returnWare/merge',
		method: 'post',
		data
	});
}

// 返仓入库
export function returnWareInbound(data) {
	const data1 = rsaEncrypt(data);
	return request({
		url: '/returnWare/insert',
		method: 'post',
		data: {
			data: data1
		}
	});
}

// 分页条件查询退货返仓记录
export function getReturnWareSelectist(data) {
	return request({
		url: '/returnWare/select',
		method: 'get',
		params: data
	});
}
